package com.acwing.partition18;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/1/31 10:09
 */
public class AC1789牛为什么过马路II {

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String s = reader.readLine();
        int[][] cattle = new int[26][2];
        for (int i = 0; i < s.length(); i++) {
            int c = s.charAt(i) - 'A';
            if (cattle[c][0] != 0) cattle[c][1] = i + 1;
            else cattle[c][0] = i + 1;
        }
        int ans = 0;
        //枚举交叉区间
        for (int i = 0; i < cattle.length; i++) {
            for (int j = 0; j < cattle.length; j++) {
                if (i == j) continue;
                int a = cattle[i][0], b = cattle[i][1], c = cattle[j][0], d = cattle[j][1];
                if (c > a && c < b && d > b) ans++;
            }
        }
        writer.write(ans + "\n");
        writer.flush();
    }
}
